/**
 * 格式化时间格式
 * @param {*} time '2025-01-01 00:00:00'
 * @returns 2025年01月01日
 */
export const FormatTime = (time) => {
    const date = new Date(time);
    return `${date.getFullYear()}年${date.getMonth()+1}月${date.getDate()}日`;
}

/**
 * 计算时间差值 规格化格式
 * @param {*} time1 '2025-01-01 00:00:00'
 * @param {*} time2 '2025-01-01 00:00:00'
 * @returns X天X小时X分钟X秒
 */
export const diffTime = (time1, time2) => {
    const date1 = new Date(time1);
    const date2 = new Date(time2);
    // 毫秒差值数
    let diff = date2 - date1
    diff = diff / 1000
    const day = Math.floor(diff / (24 * 3600))
    const hour = Math.floor((diff % (24 * 3600)) / 3600)
    const minute = Math.floor(diff % (3600) / 60)
    const second = diff % 60
    return `${day}天${hour}小时${minute}分钟${second}秒`
}